home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / characterChar.lua < prev    next >
Text File  |  2004-01-29  |  2KB  |  57 lines

  1. -- character interaction state machine
  2. beginStateMachine()
  3.     
  4.     onEnter(function(msg)
  5.         local character = getStateObjectFromID(msg.sender);
  6.         storeStateObject("character", character);
  7.         
  8.         if getParent().isOneActionPointLocked(chair) then
  9.             -- action point is locked
  10.             getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  11.             sendMsg("emoThink", getParent().walkSO);
  12.             exitStateMachine();
  13.         else
  14.             getParent().lockActionPoints(character);
  15.         end
  16.     end )
  17.     
  18.     onExit(function(msg)
  19.         local character = retrieveStateObject("character");
  20.         getParent().unlockActionPoints(character);
  21.         removeStateObject("character");
  22.     end )
  23.     
  24.     -- wait for other character
  25.     state("wait")
  26.         onEnter(function(msg)
  27.             local character = retrieveStateObject("character");
  28.             -- periodically send a message to the other
  29.             -- character that this character is ready
  30.             sendDelayedMsgThis("ready", 1000);
  31.             -- or, ofter a longer period of waiting, stop waiting
  32.             sendDelayedMsgThis("stop", 10000);
  33.         end )
  34.     
  35.         onMsg("end", function(msg)
  36.             actionComplete();
  37.         end )    
  38.     
  39.         onMsg("queue", function(msg)
  40.             exitStateMachine();
  41.         end )        
  42.     
  43.         onMsg("stop", function(msg)
  44.             exitStateMachine();
  45.         end )    
  46.         
  47.         onMsg("ready", function(msg)
  48.             -- send a message to the other character
  49.             local character = retrieveStateObject("character");
  50.             sendMsg("partnerReady", character);
  51.         end )
  52.         
  53.         onMsg("partnerReady", function(msg)
  54.             wNotify("partner is ready");
  55.         end )
  56.     
  57. endStateMachine()